﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Expect.Core.Test.Fixtures;

namespace Expect.Core.Test
{
    using Expect.Core.BaseClasses;

    [TestClass]
    public class TypeConversionTests
    {
        [TestMethod]
        public void TypeConversion_SystemTypes()
        {
            DefaultFixtureCatalog catalog = new DefaultFixtureCatalog(new DefaultNameProvider());
            catalog.ImportTypes(this.GetType().Assembly);
            var montant = (int)catalog.GetValue(typeof(int), "12");

        }

        [TestMethod]
        public void TypeConversion_CustomTypes()
        {
            DefaultFixtureCatalog catalog = new DefaultFixtureCatalog(new DefaultNameProvider());
            catalog.ImportTypes(this.GetType().Assembly);
            Assert.IsTrue(catalog.HasConverterFor(typeof(Price)), "No converter for price !!!");

            var price = (Price)catalog.GetValue(typeof(Price), "12.0 EUR");

            Assert.IsNotNull(price);
            Assert.AreEqual(12.0, price.Montant);
            Assert.AreEqual("EUR", price.Devise);
        }
    }
}
